﻿/*
--------------------------------------
File: HSV.cs
Project: Themaopdracht 7
Author: Roel Blaauwgeers
--------------------------------------
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace THO7_Team8
{
    public class HSV
    {
        private float h, s, v;


        public HSV(float h, float s, float v)
        {
            this.h = h;
            this.s = s;
            this.v = v;
        }

        public HSV(Color color)
        {
            this.h = color.GetHue();
            this.s = color.GetSaturation();
            this.v = color.GetBrightness();
        }

        public HSV(int r, int g, int b)
        {

            Color color = Color.FromArgb(r, g, b);
            h = color.GetHue();
            s = color.GetSaturation();
            v = color.GetBrightness();
            

            /*
            float min, max;

            float red = r / 255f;
            float green = g / 255f;
            float blue = b / 255f;

            min = Math.Min(red, Math.Min(green, blue));
            max = Math.Max(red, Math.Max(green, blue));

            v = max;				// Value

            if (max != 0)
            {
                s = (max - min) / max;		// Saturation

                if (max == min)
                {
                    h = 0;
                }
                else if (red == max)
                {
                    h = (green - blue) / (max - min);		// between yellow & magenta
                }
                else if (green == max)
                {
                    h = 2 + (blue - red) / (max - min);	// between cyan & yellow
                }
                else
                {
                    h = 4 + (red - green) / (max - min);	// between magenta & cyan
                }

                h *= 60f;				// degrees
                if (h < 0)
                {
                    h += 360f; //if Hue is negative add 360 to make it positif
                }
            }
            else
            {
                // r = g = b = 0		// s = 0, v is undefined
                s = 0f;
                h = 0f;

            }
             */
        }

        public float getHue()
        {
            return h;
        }

        public float getSaturation()
        {
            return s;
        }

        public float getValue()
        {
            return v;
        }
    }
}
